package com.forum.module.blog.convert.article;

import com.forum.framework.common.util.colletion.CollectionUtils;
import com.forum.framework.common.util.object.BeanUtils;
import com.forum.module.blog.controller.article.vo.ArticleRespVO;
import com.forum.module.blog.dal.dataobject.article.ArticleDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 功能:
 * 作者:ouyzh
 * 日期:2025/3/2 21:00
 */
@Mapper
public interface ArticleConvert {
    ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class);

    default List<ArticleRespVO> covertList(List<ArticleDO> list) {
        return CollectionUtils.convertList(list, this::covert);
    }

    default ArticleRespVO covert(ArticleDO articleDO) {
        return BeanUtils.toBean(articleDO, ArticleRespVO.class);
    }
}
